﻿using Abp.AspNetCore.Mvc.Controllers;
using Abp.Domain.Repositories;
using Batman.Cms.Core.Models.Mvc;
using Batman.Core;
using Batman.Jianbei.Forum.Core.ChatRoom;
using Batman.Jianbei.Forum.Core.Consts;
using Batman.Jianbei.Forum.Services.ChatRoom;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;

namespace Batman.Jianbei.Forum.Areas.Admin
{
    [Area(RouteNames.Admin)]
    [Authorize]
    public class MaskAlbumController : AbpController
    {
        public IRepository<MaskAlbum, string> repository { get; set; }

        public IRepository<Mask, string> maskRepository { get; set; }

        public MaskAlbumManager MaskAlbumManager { get; set; }

        public MaskService MaskService { get; set; }

        /// <summary>
        /// 获取到匿名身份
        /// </summary>
        /// <returns></returns>
        public IActionResult GetMasks()
        {
            var masks = maskRepository.GetQuery().ToList();
            return Json(masks);
        }

        /// <summary>
        /// 获取匿名身份
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Mask GetMask(string id)
        {
            var result = maskRepository.GetQuery()
                                       .Include(t => t.Avatar)
                                       .Where(t => t.Id == id)
                                       .FirstOrDefault();

            return result;
        }


        /// <summary>
        /// 保存昵称
        /// </summary>
        /// <param name="mask"></param>
        /// <returns></returns>
        public ResponseBase AddMask(Mask mask)
        {
            return MaskService.Save(mask);
        }

        public ResponseBase UpdateMask(Mask mask)
        {
            return MaskService.Update(mask);
        }

        /// <summary>
        /// 保存删除状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="isDeleted"></param>
        /// <returns></returns>
        public bool ChangeDeleted(string id, bool isDeleted)
        {
            return MaskService.SetDeleted(id, isDeleted);
        }

        /// <summary>
        /// 批量设置为禁用
        /// </summary>
        /// <param name="models"></param>
        /// <returns></returns>
        public bool SetDeleted(List<string> models)
        {
            return MaskService.SetDeleted(models);
        }


        /// <summary>
        /// 批量设置为启用
        /// </summary>
        /// <param name="models"></param>
        /// <returns></returns>
        public bool SetUnDeleted(List<string> models)
        {
            return MaskService.SetUnDeleted(models);
        }
    }
}
